Add non-blocking file logging and stderr error logging#7
Merged
Conversation
Add a lightweight logging system with two macros — slog! (stdout) and serr! (stderr) — that also tee to a log file via SPICEIO_LOG_FILE. The file writer runs on a dedicated OS thread fed by a bounded mpsc channel; try_send ensures logging never blocks the proxy. When no file is configured there is zero overhead (no thread, no channel, no allocation). All log lines are timestamped (ISO-8601 UTC with milliseconds) using gettimeofday — no allocations in the timestamp path. Also adds logging for: - Connection lifecycle (stdout): client TCP accept, SMB TCP connect, negotiate, auth, tree connect - All failure paths (stderr): every SMB wire error, S3 streaming errors, body read errors, access denied, client disconnects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/log.rs: non-blocking file logger backed by a dedicated OS thread with boundedmpsc::sync_channel(4096)and 64 KBBufWriter.try_sendensures the proxy is never blocked. Zero overhead when no file is configured.slog!(stdout) for lifecycle/info,serr!(stderr) for errors. Both tee to the log file whenSPICEIO_LOG_FILEis set.2026-04-02T16:09:34.123Z) viagettimeofday— zero-alloc stack buffer, no external dependencies.Test plan
make lintpasses (fmt, check, clippy, rustdoc)cargo test --locked— 200/200 tests passSPICEIO_LOG_FILE— timestamps, stdout/stderr routing, and file tee all working